/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package model.pojo;

import java.io.Serializable;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.Table;

/**
 *
 * @author Yasith
 */
@Entity
@Table(name = "posttags")
@NamedQueries({@NamedQuery(name = "PostTag.findByPostTagID", query = "SELECT p FROM PostTag p WHERE p.postTagID = :postTagID")})
public class PostTag implements Serializable {
    private static final long serialVersionUID = 1L;
    @Id
    @GeneratedValue
    @Column(name = "postTagID", nullable = false)
    private Integer postTagID;
    @JoinColumn(name = "postId", referencedColumnName = "postId")
    @ManyToOne
    private Post postId;
    @JoinColumn(name = "tagId", referencedColumnName = "tagId")
    @ManyToOne
    private Tag tagId;

    public PostTag() {
    }

    public PostTag(Integer postTagID) {
        this.postTagID = postTagID;
    }

    public Integer getPostTagID() {
        return postTagID;
    }

    public void setPostTagID(Integer postTagID) {
        this.postTagID = postTagID;
    }

    public Post getPostId() {
        return postId;
    }

    public void setPostId(Post postId) {
        this.postId = postId;
    }

    public Tag getTagId() {
        return tagId;
    }

    public void setTagId(Tag tagId) {
        this.tagId = tagId;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (postTagID != null ? postTagID.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof PostTag)) {
            return false;
        }
        PostTag other = (PostTag) object;
        if ((this.postTagID == null && other.postTagID != null) || (this.postTagID != null && !this.postTagID.equals(other.postTagID))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "model.pojo.PostTag[postTagID=" + postTagID + "]";
    }

}
